'use strict';

/**
 * @ngdoc function
 * @name jgappApp.controller:SignFootmarkdetailCtrl
 * @description
 * # SignFootmarkdetailCtrl
 * Controller of the jgappApp
 */
angular.module('jgappApp')
  .controller('SignFootmarkdetailCtrl', function (MapService, $scope, Util, localStorageService) {
var markPonits = localStorageService.get("markPonits");
    var vm = this;
    // 默认地址坐标
    var point = {
      longitude: markPonits[0].lng,
      latitude: markPonits[0].lat
    };
    this.title = "位置信息";
    this.ak = MapService.getAk();
    // 初始化地图
    var initMap = function () {
      vm.offlineOpts = { retryInterval: 5000 };
      vm.mapOptions = {
        center: point,
        zoom: 14,
        city: "NanChang",
        enableDragging: false
      };
    };
    var addAllMasker = function () {
      vm.map.clearOverlays();
      markPonits.forEach(function (data, index) {
        addMarker(new BMap.Point(data.lng, data.lat),index+1)
      });
      function addMarker(point,index) {
        var marker = new BMap.Marker(point);
        var label = new BMap.Label(index, { offset: new BMap.Size(20, -10) });
        marker.setLabel(label);
        vm.map.addOverlay(marker);
      }
    }
    this.finishmap = function (map, previousMarkers) {
      vm.map = map
      vm.previousMarkers = previousMarkers;
      addAllMasker()
    };
    initMap()
  });
